<?php
/*
 * 手机客户端店铺-商品评价列表接口
 * 2014-02-26
 * 2014-05-08 (已查) 
 */
include "inc/public_header.php";


$reJson = array(); //构建返回值

$product_id 			= $_REQUEST["goodsId"];	//商品id
$page			= $_REQUEST["page"]; 			//页数，第一页为0
$pagesize		= $_REQUEST["pagesize"];		//每页记录数

if(!isset($page)){
	$page = 0;
}
if(!isset($pagesize)){
	$pagesize = 20; //默认每页20条
}

$reJson["success"] = "1";

//评论条数
$sql = "select 
			count(product_id) as ct 
		from 
			shop_product_assess 
		where 
			product_id = '".$product_id."'
		";
$db1->query($sql);
$db1->next_record();
$reJson["count"] = $db1->f("ct");

//商品评价列表
$sql = "SELECT a.msg,b.mobile,c.nickname,DATE(a.addtime) as date FROM shop_product_assess a INNER JOIN user_base b on a.uid=b.uid INNER JOIN new_weituo_person c on a.uid=c.uid where a.product_id='".$product_id."' order by a.assess_id desc"; 
$db->query($sql);
$commentArr = array();
while($db->next_record()){
	$msg	   	= $db->f("msg");
	if ($db->f("nickname")){
	$nickname	= $db->f("nickname");
	}else{
	$nickname 	= $db->f("mobile");
	}
	$date	   	= $db->f("date");
	$commentArr[] = array(
		"content"=>$msg					//评论内容
		,"person"=>$nickname			//评价人(用户昵称，或者电话号码)
		,"date"=>$date					//评论日期
	);
}			
//放入商品评价列表
$reJson["list"] = $commentArr;

echo json_encode($reJson);
?>
